package com.wuwei.baseproject.presenter;

import com.wuwei.baseproject.basemvp.BasePresenter;
import com.wuwei.baseproject.bean.BaseObjectBean;
import com.wuwei.baseproject.bean.MyFocus;
import com.wuwei.baseproject.contact.DemoContact;
import com.wuwei.baseproject.model.DemoModel;
import com.wuwei.baseproject.net.RxScheduler;
import io.reactivex.functions.Consumer;

/**
 * Created by asus on 2018/5/16.
 */

public class DemoPresenter extends BasePresenter<DemoContact.View> implements  DemoContact.Presenter{

//    void getMyFollowList(String baseUrl, String meid,String currentPage,String showCount);

    private DemoContact.Model model;

    public DemoPresenter() {
        model = new DemoModel();
    }

    @Override
    public void getMyFollowList( String meid, String currentPage, String showCount) {
        //View是否绑定 如果没有绑定，就不执行网络请求
        if (!isViewAttached()) {
            return;
        }
        mView.showLoading();
        model.getMyFollowList(meid, currentPage,showCount)
                .compose(RxScheduler.<MyFocus>Flo_io_main())
                .as(mView.<MyFocus>bindAutoDispose())
                .subscribe(new Consumer<MyFocus>() {
                    @Override
                    public void accept(MyFocus bean) throws Exception {
                        mView.onSuccess(bean);
                        mView.hideLoading();
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        mView.onError(throwable);
                        mView.hideLoading();
                    }
                });
    }
}
